#include <vector>

using namespace std;

class Solution {
public:
    vector<int> singleNumbers(vector<int>& nums) {
        uint32_t res = 0;
        for (int& num : nums) {
            res ^= num;
        }
        uint32_t i = 0;
        for (; i < 32; i++) {
            if ((res & 1) == 1) {
                break;
            }
            res >>= 1;
        }
        uint32_t res1 = 0;
        uint32_t res2 = 0;
        for (int& num : nums) {
            if (((num >> i) & 1) == 1) {
                res1 ^= num;
            } else {
                res2 ^= num;
            }
        }
        return vector<int>{(int) res1, (int) res2};
    }
};